<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<html>
<%
    pageContext.setAttribute("path", request.getContextPath());
%>
<head>
    <title>Title</title>
    <!-- 引入-->
    <script type="text/javascript" src="${path}/js/jquery-1.11.0.min.js"></script>

    <script type="text/javascript">
        $(function () {
                $('#btn_add').click(function () {
                   //js发送请求
                   var dname= $('#add_dname').val()
                    console.info(dname)
                    $.ajax({
                        url:'${path}/deptv3/add',
                        async:true,
                        data:'{"did":"","dname":"'+dname+'"}',
                        type:"post",
                        contentType:"application/json;charset=UTF-8",
                        success:function (result) {    //js接收结果
                            if(200==result.code){
                                alert(result.msg) //js更新页面
                                //刷新列表
                            }
                        },
                        error:function () {
                            alert('服务问题，请求失败')
                        }
                    });



                })
        })
    </script>
</head>
<body>

    <div id="addDiv">
        <h1>添加页面</h1>
        <form id="add_form"  >
            <input type="hidden" name="did" id="add_did"/><br/>
            <input type="text" name="dname" id="add_dname"/><br/>
            <input id="btn_add" type="button" value="保存"/><br/>
        </form>
    </div>

</body>
</html>
